home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / utmisc1 / maprz2_e.lha / MapRZ2_EVD1_1 / Source / RetinaZ2mapped.asm < prev    next >
Assembly Source File  |  1996-05-06  |  8KB  |  377 lines

  1. *
  2. * ShapeShifter external video driver for Retina Z2
  3. *
  4. * $VER: RetinaZ2mapped.asm 1.1 (3.5.96)
  5. *
  6. * Christoph Niedeggen 24.12.95-30.12.95
  7. * based on code by Christian Bauer
  8. *
  9. * History:
  10. *
  11. *  V1.1 : Patch to remove a bug in Retina_OpenScreen parameters,
  12. *         provided by Christophe Labouisse <labouiss@sncf.fr>
  13. *  V1.0 : First Release version.
  14.  
  15.         MACHINE    68020
  16.  
  17.         INCLUDE    "exec/types.i"
  18.         INCLUDE    "exec/macros.i"
  19.         INCLUDE    "exec/memory.i"
  20.         INCLUDE    "intuition/intuition.i"
  21.         INCLUDE    "utility/tagitem.i"
  22.         INCLUDE    "exec/alerts.i"
  23.         INCLUDE    "libraries/retina.i"
  24.         INCLUDE    "libraries/retina_lib.i"
  25.         INCLUDE    "shapeextvideo.i"
  26.  
  27. *
  28. * Offset for linear mapped RetinaZ2 RAM
  29. *
  30.  
  31. C_RL_START    equ    $01c00000
  32.  
  33. *
  34. * Definition of our private context structure for storing local variables
  35. *
  36.  
  37.  STRUCTURE    MyContext,0
  38.     APTR    conIntuitionBase
  39.     APTR    conRetinaBase
  40.  
  41.     APTR    conScreen    ;The screen
  42.     APTR    conRetinaScr    ;The screen's RetinaScreen
  43.  
  44.     STRUCT    conRGBBuf,256*3    ;Buffer for LoadRGB32
  45.  
  46.     WORD    conVideoMode    ;Video mode (VMODE_*)
  47.  LABEL    MyContext_SIZEOF
  48.  
  49. *
  50. * This is the driver header
  51. *
  52.  
  53.         EVHEADER DriverTags
  54.  
  55. *
  56. * The header tags that describe the driver and provide pointers to
  57. * the driver's routines
  58. *
  59.  
  60. DriverTags    dc.l    SHEV_Level,1        ;Interface level 1
  61.         dc.l    SHEV_Version,0
  62.         dc.l    SHEV_Revision,1
  63.         dc.l    SHEV_Name,DriverName
  64.         dc.l    SHEV_ID,DriverID
  65.         dc.l    SHEV_Author,DriverAuthor
  66.  
  67.         dc.l    SHEV_OpenScreen,MyOpenScreen
  68.         dc.l    SHEV_CloseScreen,MyCloseScreen
  69.         dc.l    SHEV_LoadRGB32,MyLoadRGB32
  70.         dc.l    SHEV_Refresh,MyRefresh
  71.         dc.l    TAG_END,0
  72.  
  73. DriverName    dc.b    "Retina Z2 mapped Driver",0
  74.         CNOP    0,4
  75. DriverID    dc.b    "$VER: RetinaZ2mapped 1.0 (30.12.95)",13,10,0
  76.         CNOP    0,4
  77. DriverAuthor    dc.b    "Christoph Niedeggen",0
  78.         CNOP    0,4
  79.  
  80. *
  81. * The OpenScreen routine
  82. * a0: Taglist with input parameters
  83. * a1: Taglist with output parameters
  84. * a6: Base of utility.library
  85. *
  86.  
  87. MyOpenScreen    movem.l    d2-d7/a2-a6,-(sp)
  88.         move.l    a0,a4            ;a4: Input taglist
  89.         move.l    a1,a5            ;a5: Output taglist
  90.         move.l    a6,_UtilityBase
  91.         move.l    (4).w,_ExecBase
  92.  
  93. ; Allocate memory for context
  94.         move.l    _ExecBase,a6
  95.         move.l    #MyContext_SIZEOF,d0
  96.         move.l    #MEMF_PUBLIC|MEMF_CLEAR,d1
  97.         JSRLIB    AllocVec
  98.         tst.l    d0
  99.         beq    OpenFailed
  100.         move.l    d0,a2            ;a2: Context
  101.  
  102. ; Open intuition.library
  103.         move.l    _ExecBase,a6
  104.         lea    IntuitionName,a1
  105.         moveq    #37,d0
  106.         JSRLIB    OpenLibrary
  107.         move.l    d0,conIntuitionBase(a2)
  108.         beq    OpenFailed
  109.  
  110. ; Open retina.library
  111.         move.l    _ExecBase,a6
  112.         lea    RetinaName,a1
  113.         moveq    #0,d0
  114.         JSRLIB    OpenLibrary
  115.         move.l    d0,conRetinaBase(a2)
  116.         beq    OpenFailed
  117.  
  118. ; Store context pointer in output taglist
  119.         move.l    _UtilityBase,a6
  120.         move.l    a5,a0
  121.         move.l    #SHEV_Context,d0
  122.         JSRLIB    FindTagItem
  123.         move.l    d0,a0
  124.         move.l    a2,ti_Data(a0)
  125.  
  126. ; Get video mode and set the refresh type and screen depth accordingly
  127. ; This driver only supports VMODE_8BIT
  128.         move.l    _UtilityBase,a6
  129.         move.l    a4,a0
  130.         move.l    #SHEV_VideoMode,d0
  131.         moveq    #VMODE_1BIT,d1        ;Dummy default
  132.         JSRLIB    GetTagData
  133.         move.w    d0,conVideoMode(a2)
  134.  
  135.         cmp.l    #VMODE_8BIT,d0
  136.         bne    OpenFailed
  137.         move.l    a5,a0
  138.         move.l    #SHEV_RefreshType,d0
  139.         JSRLIB    FindTagItem
  140.         tst.l    d0
  141.         beq    10$
  142.         move.l    d0,a1
  143.         move.l    #RTYPE_CUSTOM,ti_Data(a1)    ;to get Vector at $8 patched
  144. 10$
  145.  
  146. ; Extract screen parameters from input taglist
  147.         move.l    _UtilityBase,a6
  148.         move.l    a4,a0
  149.         move.l    #SHEV_ScreenX,d0
  150.         moveq    #0,d1
  151.         JSRLIB    GetTagData
  152.         move.l    d0,ScrWidth
  153.  
  154.         move.l    a4,a0
  155.         move.l    #SHEV_ScreenY,d0
  156.         moveq    #0,d1
  157.         JSRLIB    GetTagData
  158.         move.l    d0,ScrHeight
  159.  
  160. ; Open the screen and store pointer in output taglist
  161.  
  162.         move.l    ScrWidth,d0
  163.         move.l    ScrHeight,d1
  164.         moveq    #-$1,d2                ;MID_DEFAULT_8
  165.         moveq    #$0,d3                
  166.         sub.l    a0,a0
  167.         move.l    conRetinaBase(a2),a6
  168.         jsr    _LVORetina_OpenScreen(a6)
  169.         move.l    d0,conRetinaScr(a2)
  170.         beq    OpenFailed
  171.  
  172.         move.l    conIntuitionBase(a2),a6
  173.         sub.l    a0,a0
  174.         lea    ScreenTags,a1
  175.         JSRLIB    OpenScreenTagList
  176.         move.l    d0,a3            ;a3: Screen
  177.         move.l    d0,conScreen(a2)
  178.         beq    OpenFailed
  179.         bra    ScreenOpened
  180.  
  181. ScreenOpened    move.l    _UtilityBase,a6
  182.         move.l    a5,a0
  183.         move.l    #SHEV_Screen,d0
  184.         JSRLIB    FindTagItem
  185.         move.l    d0,a0
  186.         move.l    a3,ti_Data(a0)
  187.  
  188. ; Extract all the other data that the caller wants
  189.         move.l    _UtilityBase,a6
  190.         move.l    a5,a0
  191.         move.l    #SHEV_ScreenBase,d0
  192.         JSRLIB    FindTagItem
  193.         tst.l    d0
  194.         beq    1$
  195.         move.l    d0,a1
  196.         move.l    conRetinaScr(a2),a0
  197.         move.l    _rs_BitMap(a0),a0
  198.         move.l    a0,d0
  199.         add.l    #C_RL_START,d0            ;CN24.12.95
  200.         move.l    d0,ti_Data(a1)
  201. 1$
  202.         move.l    _UtilityBase,a6
  203.         move.l    a5,a0
  204.         move.l    #SHEV_BytesPerRow,d0
  205.         JSRLIB    FindTagItem
  206.         tst.l    d0
  207.         beq    2$
  208.         move.l    d0,a1
  209.         move.l    conRetinaScr(a2),a0
  210.         moveq    #0,d0
  211.         move.w    _rs_Modulo(a0),d0
  212.         move.l    d0,ti_Data(a1)
  213. 2$
  214.  
  215. ; Everything is OK
  216.         movem.l    (sp)+,d2-d7/a2-a6
  217.         moveq    #0,d0
  218.         rts
  219.  
  220. ; An error occurred
  221. OpenFailed    movem.l    (sp)+,d2-d7/a2-a6
  222.         moveq    #-1,d0
  223.         rts
  224.  
  225. *
  226. * The CloseScreen routine
  227. * a0: Taglist with input parameters
  228. * a1: Taglist with output parameters
  229. * a2: Context pointer (never NULL)
  230. * a6: Base of utility.library
  231. *
  232.  
  233. MyCloseScreen    movem.l    d2-d7/a2-a6,-(sp)
  234.  
  235. ; Close the screen
  236.         move.l    conScreen(a2),d0
  237.         beq    1$
  238.         move.l    d0,a0
  239.         move.l    conIntuitionBase(a2),a6
  240.         JSRLIB    CloseScreen
  241. 1$
  242.         move.l    conRetinaScr(a2),d0
  243.         beq    2$
  244.         move.l    d0,a0
  245.         move.l    conRetinaBase(a2),a6
  246.         jsr    _LVORetina_CloseScreen(a6)
  247. 2$
  248.  
  249. ; Close retina.library
  250.         move.l    conRetinaBase(a2),d0
  251.         beq    3$
  252.         move.l    d0,a1
  253.         move.l    _ExecBase,a6
  254.         JSRLIB    CloseLibrary
  255. 3$
  256.  
  257. ; Close intuition.library
  258.         move.l    conIntuitionBase(a2),d0
  259.         beq    6$
  260.         move.l    d0,a1
  261.         move.l    _ExecBase,a6
  262.         JSRLIB    CloseLibrary
  263. 6$
  264.  
  265. ; Free context
  266.         move.l    _ExecBase,a6
  267.         move.l    a2,a1
  268.         JSRLIB    FreeVec
  269.  
  270. CloseDone    movem.l    (sp)+,d2-d7/a2-a6
  271.         moveq    #0,d0
  272.         rts
  273.  
  274. *
  275. * The LoadRGB32 routine
  276. * a0: Taglist with input parameters
  277. * a1: Taglist with output parameters
  278. * a2: Context pointer
  279. * a6: Base of utility.library
  280. *
  281.  
  282. ; Get pointer to 32 bit color table
  283. MyLoadRGB32    movem.l    d2-d7/a2-a6,-(sp)
  284.         move.l    a0,a4        ;a4: Input taglist
  285.         move.l    #SHEV_ColorTable,d0
  286.         moveq    #0,d1
  287.         JSRLIB    GetTagData
  288.         move.l    d0,a0        ;a0: Color table
  289.  
  290. ; Convert to 8 bit color table
  291.         lea    conRGBBuf(a2),a1
  292.         move.w    #256*3-1,d1
  293. 1$        move.l    (a0)+,d0
  294.         rol.l    #8,d0
  295.         move.b    d0,(a1)+
  296.         dbra    d1,1$
  297.  
  298. ; Activate palette
  299.         move.l    conRetinaBase(a2),a6
  300.         move.l    conRetinaScr(a2),a0
  301.         moveq    #0,d0        ;Start with color #0
  302.         move.l    #256,d1        ;Load 256 colors
  303.         lea    conRGBBuf(a2),a1
  304.         jsr    _LVORetina_LoadPalette(a6)
  305.  
  306.         movem.l    (sp)+,d2-d7/a2-a6
  307.         moveq    #0,d0
  308.         rts
  309.  
  310.  
  311. MyRefresh    movem.l    a5-a6,-(sp)
  312.  
  313.         move.l    (4).w,a6
  314.         lea    setVBR(pc),a5
  315.         jsr    -$001e(a6)            ;Supervisor()
  316.  
  317.         movem.l    (sp)+,a5-a6
  318.         rts
  319.  
  320. setVBR        movec.l    VBR,a0
  321.         move.l    $8(a0),$8
  322.         rte
  323.  
  324. *
  325. * Constants
  326. *
  327.  
  328. ; Library names
  329. IntuitionName    dc.b    "intuition.library",0
  330. GfxName        dc.b    "graphics.library",0
  331. DOSName        dc.b    "dos.library",0
  332. RetinaName    dc.b    "retina.library",0
  333. RetinaEmuName    dc.b    "retinaemu.library",0
  334.  
  335. ; The name of our screen
  336. ScreenName    dc.b    "ShapeShifter Screen",0
  337.         CNOP    0,4
  338.  
  339. *
  340. * Data section
  341. *
  342.  
  343.         SECTION    "DATA",DATA
  344.  
  345. ; Taglist for OpenScreen()
  346. ; Note that it's only safe to use this structure here because
  347. ;  the SHEV_OpenScreen routine is guaranteed not to be called
  348. ;  more than once at a time. The buffer for LoadRGB32, however,
  349. ;  is declared in the Context and not in the BSS segment because
  350. ;  that routine may be called multiple times for multiple
  351. ;  screens.
  352. ScreenTags    dc.l    SA_Depth            ;screen with 16x16 pixels, 1 bit
  353.         dc.l    1                ;(just to provide intuition screen for input)
  354.         dc.l    SA_Width
  355.         dc.l    16
  356.         dc.l    SA_Height
  357.         dc.l    16
  358.         dc.l    SA_Quiet,-1
  359.         dc.l    SA_Title,ScreenName
  360.         dc.l    TAG_END,0
  361.  
  362. ;values for Retina screen
  363. ScrWidth    dc.l    0
  364. ScrHeight    dc.l    0
  365.  
  366. *
  367. * BSS section
  368. *
  369.  
  370.         SECTION    "BSS",BSS
  371.  
  372. ; Library base pointers
  373. _ExecBase    ds.l    1
  374. _UtilityBase    ds.l    1
  375.  
  376.         END
  377.